home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / nihcl-30.lha / nihcl-3.0 / test / linkedlist.c < prev    next >
C/C++ Source or Header  |  1990-05-19  |  3KB  |  94 lines

  1. /* Test class LinkedList
  2.  
  3.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  4.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  5.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  6.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  7.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  8.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  9.  
  10. Author:
  11.     K. E. Gorlen
  12.     Bg. 12A, Rm. 2033
  13.     Computer Systems Laboratory
  14.     Division of Computer Research and Technology
  15.     National Institutes of Health
  16.     Bethesda, Maryland 20892
  17.     Phone: (301) 496-1111
  18.     uucp: uunet!nih-csl!kgorlen
  19.     Internet:kgorlen@alw.nih.gov
  20.  
  21. Function:
  22.     
  23. Modification History:
  24.     
  25. $Log:    linkedlist.c,v $
  26.  * Revision 3.0  90/05/20  00:29:25  kgorlen
  27.  * Release for 1st edition.
  28.  * 
  29. */
  30. static char rcsid[] = "$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/test/RCS/linkedlist.c,v 3.0 90/05/20 00:29:25 kgorlen Rel $";
  31.  
  32. #include "Point.h"
  33. #include "LinkedList.h"
  34. #include "LinkOb.h"
  35. #include "Set.h"
  36.  
  37. main()
  38. {
  39.     cout << "\nTest class LinkedList" << endl;
  40.     Point A(1,1);
  41.     Point B(1,2);
  42.     Point C(1,3);
  43.     Point D(1,3);
  44.     LinkOb bA(A);
  45.     LinkOb bB(B);
  46.     LinkOb bC(C);
  47.     LinkOb bD(D);
  48.     LinkedList b;
  49.     b.add(bA);
  50.     b.add(bB);
  51.     b.add(bC);
  52.     b.add(bD);
  53.     LinkedList& c = *LinkedList::castdown(b.deepCopy());
  54.     cout << "b = " << b << endl;
  55.     cout << "b.first(): " << *(b.first()) << endl;
  56.     cout << "b.last(): " << *(b.last()) << endl;
  57.     cout << "b[3]: " << *b[3] << endl;
  58.     b.reSize(30);
  59.     cout << "b.includes(C): " << b.includes(C) << endl;
  60.     cout << "c == b: " << (c==b) << endl;
  61.     b.addFirst(*new LinkOb(*new Point(1,0)));
  62.     b.addLast(*new LinkOb(*new Point(1,19)));
  63.     cout << "b = " << b << endl;
  64.     b.addAll(c);
  65.     cout << "b = " << b << endl;
  66.     b.remove(*b[1]);
  67.     cout << "b.includes(A): " << b.includes(A) << endl;
  68.     cout << "b = " << b << endl;
  69.     cout << "c == b: " << (c==b) << endl;
  70.     cout << "b.indexOf(D): " << b.indexOf(D) << endl;
  71.     cout << "c = " << c << endl;
  72.     DO(c,Object,ob) cout << *ob; OD
  73.     cout << endl;
  74.     cout << "c.size() = " << c.size() << endl;
  75.     LinkOb::castdown(c[1])->value(A);
  76.     cout << "c = " << c << endl;
  77.     while (c.size() != 0) {
  78.         c.remove(*c.first());
  79.         cout << "c = " << c << endl;
  80.     }
  81.     cout << "b.asSet(): " << (b.asSet()) << endl;
  82.     b.removeAll();
  83.     b.add(bA);
  84.     b.add(bC);
  85.     b.addAfter(bA,bB);
  86.     b.addAfter(bC,bD);
  87.     D = Point(1,4);
  88.     cout << "b = " << b << endl;
  89.     cout << "b.first(): " << *(b.first()) << endl;
  90.     cout << "b.last(): " << *(b.last()) << endl;
  91.     cout << "b.size(): " << b.size() << endl;
  92.     b.removeAll();
  93. }
  94.